{{ 'component-image-with-text.css' | asset_url | stylesheet_tag }}
<style>
  @media screen and (max-width: 900px) {
    .tenways-index .tenways_images-text .class-index .grid__item .image-with-text__content {
      padding: 60px 20px 30px;
    }
    
    .tenways-index .tenways_images-text .class-index .grid__item .app-img  img {
      width: 100%;
    }
    
    .tenways-index .image-with-text .grid__item .image-with-text__text p {
      font-size: 14px;
      line-height: 2.2rem;
    }
  }
</style>
<div class="image-with-text {% if section.settings.full_width %}image-with-text--full-width{% else %}page-width{% endif %} color-scheme-{{ section.settings.color_scheme }}">
  {%- if section.settings.header != blank -%}
  <div class="title">
   <span>{{ section.settings.header }}</span>
  </div>
{% endif %}
  <div class="image-with-text__grid class-index color-{{ section.settings.color_scheme }} grid grid--gapless grid--1-col grid--2-col-tablet gradient{% if section.settings.layout == 'text_first' %} image-with-text__grid--reverse{% endif %}">
    <div class="grid__item">
      {%- if section.settings.button_link != blank -%}
        <a{% if section.settings.button_link != blank %} href="{{ section.settings.button_link }}"{% endif %} class="no-underline"{% if section.settings.button_link == blank %} aria-disabled="true"{% endif %}>
    {% endif %}
      <div class="hover-img image-with-text__media image-with-text__media--{{ section.settings.height }} {% if section.settings.image != blank %}media{% else %}image-with-text__media--placeholder placeholder{% endif %}"
        {% if section.settings.height == 'adapt' and section.settings.image != blank %} style="padding-bottom: {{ 1 | divided_by: section.settings.image.aspect_ratio | times: 100 }}%;"{% endif %}
      >
        {%- if section.settings.image != blank -%}
          <img
            srcset="{%- if section.settings.image.width >= 165 -%}{{ section.settings.image | img_url: '165x' }} 165w,{%- endif -%}
              {%- if section.settings.image.width >= 323 -%}{{ section.settings.image | img_url: '323x' }} 323w,{%- endif -%}
              {%- if section.settings.image.width >= 360 -%}{{ section.settings.image | img_url: '360x' }} 360w,{%- endif -%}
              {%- if section.settings.image.width >= 535 -%}{{ section.settings.image | img_url: '535x' }} 535w,{%- endif -%}
              {%- if section.settings.image.width >= 750 -%}{{ section.settings.image | img_url: '750x' }} 750w,{%- endif -%}
              {%- if section.settings.image.width >= 1070 -%}{{ section.settings.image | img_url: '1070x' }} 1070w,{%- endif -%}
              {%- if section.settings.image.width >= 1500 -%}{{ section.settings.image | img_url: '1500x' }} 1500w,{%- endif -%}
              {{ section.settings.image | img_url: 'master' }} {{ section.settings.image.width }}w"
              data-src="{{ section.settings.image | img_url: '1500x' }}"
            sizes="(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 2 }}px, (min-width: 750px) calc((100vw - 130px) / 2), calc((100vw - 50px) / 2)"
            alt="{{ section.settings.image.alt | escape }}"
            loading="lazy"
            class="lazyload"
            width="{{ section.settings.image.width }}"
            height="{{ section.settings.image.height }}"
          >
        {%- else -%}
          {{ 'image' | placeholder_svg_tag: 'placeholder-svg' }}
        {%- endif -%}
      </div>
      {%- if section.settings.button_link != blank -%}
      </a>
     {% endif %}
    </div>
    <div class="grid__item">
      <div class="image-with-text__content image-with-text__content--{{ section.settings.height }}">
        {%- for block in section.blocks -%}
          {% case block.type %}
            {%- when 'heading' -%}
              <h2 class="image-with-text__heading h1" {{ block.shopify_attributes }}>
                {{ block.settings.heading | escape }}
              </h2>
            {%- when 'title' -%}
              <h2 class="text" {{ block.shopify_attributes }}>
                {{ block.settings.richtext }}
              </h2>
            {%- when 'text' -%}
              <div class="image-with-text__text rte" {{ block.shopify_attributes }}>{{ block.settings.text }}</div>
            {%- when 'button' -%}
              {%- if block.settings.button_label != blank -%}
                <a{% if block.settings.button_link != blank %} href="{{ block.settings.button_link }}"{% endif %} class="button{% if block.settings.button_style_secondary %} button--secondary{% else %} button--primary{% endif %}"{% if block.settings.button_link == blank %} aria-disabled="true"{% endif %} {{ block.shopify_attributes }}>
                  {{ block.settings.button_label | escape }}
                </a>
              {%- endif -%}
              {%- when 'app' -%}
                <div class="app-img" {{ block.shopify_attributes }}>
                  <span>
                    <img loading="lazy" src="https://cdn.shopifycdn.net/s/files/1/0592/2167/2098/files/app-store.png?v=1673338992"  width="120" height="40" style="max-width:120px;margin:0;" alt="app-store">
                  </span>
                  <span>
                    <img loading="lazy" src="https://cdn.shopifycdn.net/s/files/1/0592/2167/2098/files/google-play.png?v=1673338992" width="135" height="40" style="max-width:135px" alt="google-play">
                  </span>
              </div>
          {%- endcase -%}
        {%- endfor -%}
      </div>
    </div>
  </div>
</div>

{% if section.settings.back != blank %}
 <div class="page-width">
  <div class="element-join">
  <a href="{{ section.settings.back_url }}" class="link animate-arrow">
    <span class="icon-wrap">{% render 'icon-bigJoin' %}</span>
    {%- if section.settings.back -%}
      {{ section.settings.back | escape }}
    {%- endif -%}
  </a>
</div>
 </div>
{% endif %}

{% schema %}
{
  "name": "t:sections.image-with-text.name",
  "class": "spaced-section spaced-section--full-width tenways_images-text",
  "settings": [
  {
    "type": "text",
    "id": "header",
    "label": "Title"
   },
    {
      "type": "image_picker",
      "id": "image",
      "label": "t:sections.image-with-text.settings.image.label"
    },
    {
    "type": "url",
    "id": "button_link",
    "label": "t:sections.image-with-text.blocks.button.settings.button_link.label"
    },
    {
      "type": "select",
      "id": "height",
      "options": [
        {
          "value": "adapt",
          "label": "t:sections.image-with-text.settings.height.options__1.label"
        },
        {
          "value": "small",
          "label": "t:sections.image-with-text.settings.height.options__2.label"
        },
        {
          "value": "large",
          "label": "t:sections.image-with-text.settings.height.options__3.label"
        }
      ],
      "default": "adapt",
      "label": "t:sections.image-with-text.settings.height.label"
    },
    {
      "type": "select",
      "id": "color_scheme",
      "options": [
        {
          "value": "background-1",
          "label": "t:sections.image-with-text.settings.color_scheme.options__1.label"
        },
        {
          "value": "background-2",
          "label": "t:sections.image-with-text.settings.color_scheme.options__2.label"
        },
        {
          "value": "inverse",
          "label": "t:sections.image-with-text.settings.color_scheme.options__3.label"
        },
        {
          "value": "accent-1",
          "label": "t:sections.image-with-text.settings.color_scheme.options__4.label"
        },
        {
          "value": "accent-2",
          "label": "t:sections.image-with-text.settings.color_scheme.options__5.label"
        }
      ],
      "default": "background-1",
      "label": "t:sections.image-with-text.settings.color_scheme.label"
    },
    {
      "type": "select",
      "id": "layout",
      "options": [
        {
          "value": "image_first",
          "label": "t:sections.image-with-text.settings.layout.options__1.label"
        },
        {
          "value": "text_first",
          "label": "t:sections.image-with-text.settings.layout.options__2.label"
        }
      ],
      "default": "image_first",
      "label": "t:sections.image-with-text.settings.layout.label",
      "info": "t:sections.image-with-text.settings.layout.info"
    },
    {
        "type": "text",
        "id": "back",
        "label": "Back"
    },
    {
      "type": "url",
      "id": "back_url",
      "label": "Back url"
    }
  ],
  "blocks": [
    {
      "type": "heading",
      "name": "t:sections.image-with-text.blocks.heading.name",
      "settings": [
        {
          "type": "text",
          "id": "heading",
          "default": "Image with text",
          "label": "t:sections.image-with-text.blocks.heading.settings.heading.label"
        }
      ]
    },
    {
      "type": "title",
      "name": "title",
      "settings": [
        {
          "type": "richtext",
          "id": "richtext",
          "label": "Richtext"
        }
      ]
    },
    {
      "type": "text",
      "name": "t:sections.image-with-text.blocks.text.name",
      "settings": [
        {
          "type": "richtext",
          "id": "text",
          "default": "<p>Pair text with an image to focus on your chosen product, collection, or blog post. Add details on availability, style, or even provide a review.</p>",
          "label": "t:sections.image-with-text.blocks.text.settings.text.label"
        }
      ]
    },
    {
      "type": "button",
      "name": "t:sections.image-with-text.blocks.button.name",
      "settings": [
        {
          "type": "text",
          "id": "button_label",
          "default": "Button label",
          "label": "t:sections.image-with-text.blocks.button.settings.button_label.label",
          "info": "t:sections.image-with-text.blocks.button.settings.button_label.info"
        },
        {
          "type": "url",
          "id": "button_link",
          "label": "t:sections.image-with-text.blocks.button.settings.button_link.label"
        }
      ]
    },
    {
      "type": "app",
      "name": "app",
      "limit": 1
    }
  ],
  "presets": [
    {
      "name": "t:sections.image-with-text.presets.name",
      "blocks": [
        {
          "type": "heading"
        },
        {
          "type": "text"
        },
        {
          "type": "button"
        }
      ]
    }
  ]
}
{% endschema %}
